package com.ch04.ex42;


import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;

/**
 * Created by zc on 2016/2/18.
 */
public class ExecutableTask implements Callable<String> {
    private String name;

    public String getName() {
        return name;
    }

    public ExecutableTask(String name) {
        this.name = name;
    }

    @Override
    public String call() throws Exception {
        long duration = (long) (Math.random()*10);
        System.out.printf("%s: Waiting %d seconds for results.\n",
                name, duration);
        TimeUnit.SECONDS.sleep(duration);
        return "Hello, world. I'm " + name;
    }
}
